package com.sxhuayuan.parking.controller.open.resp;

import java.util.ArrayList;
import java.util.List;

import com.sxhuayuan.parking.entity.Order;
import com.sxhuayuan.parking.utils.SettingUtils;

import lombok.Getter;
import lombok.Setter;

/**
 * 查询车辆是否已缴费，主要返回是否结清费用，和最后一笔订单的情况
 * 
 * @author gy
 */
@Setter
@Getter
public class ParkQueryIsPassableResp {

	static final List<ParkOrder> EmptyList = new ArrayList<>(0);

	public static final int TRUE = 1;
	public static final int FALSE = 0;

	// 是否放行，1放行，0不放行
	private Integer passable = FALSE;

	private String uniqueId;

	// private Float parkFee;

	private List<ParkOrder> orders = EmptyList;

	public ParkQueryIsPassableResp(String uniqueId) {
		super();
		this.uniqueId = uniqueId;
	}

	public void passableYes() {
		setPassable(TRUE);
	}

	public void passableNo() {
		setPassable(FALSE);
	}

	public void addOrders(List<Order> orderList) {
		orders = new ArrayList<ParkOrder>(orderList.size());
		orderList.stream().forEach((order) -> {
			ParkOrder o = new ParkOrder();
			o.setTradeNo(order.getSn());
			o.setFee(SettingUtils.get().setScale(order.getMoney()).floatValue());
			o.setInTime(order.getEntertime());
			o.setStartTime(order.getStarttime());
			o.setEndTime(order.getEndtime());
			o.setPlatform(order.getPlatform().ordinal());
			o.setPayMethod(order.getMethod().ordinal());
			orders.add(o);
		});
	}
}
